//-----------------------------------------------------------------------
// <copyright file="UserOfficeService.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using MyFramework;
using MIMS.WRS.Entities;
using MIMS.WRS.Data;
    
namespace MIMS.WRS.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class UserOfficeService
    {
        #region UserOffice

        public static void CreateUserOffice(UserOffice userOffice)
        {            
            try
            {
                UserOfficeDAO userOfficeDAO = new UserOfficeDAO();
                userOfficeDAO.CreateUserOffice(userOffice);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateUserOfficeException, ex);
            }
        }        

        public static void UpdateUserOffice(UserOffice userOffice)
        {            
            try
            {
                UserOfficeDAO userOfficeDAO = new UserOfficeDAO();
                userOfficeDAO.UpdateUserOffice(userOffice);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateUserOfficeException, ex);
            }
        }        

        public static void DeleteUserOffice(int officeID, int userID)
        {            
            try
            {
                UserOfficeDAO userOfficeDAO = new UserOfficeDAO();
                userOfficeDAO.DeleteUserOffice(officeID, userID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteUserOfficeException, ex);
            }
        }
        
        public static UserOffice GetUserOffice(int officeID, int userID)
        {            
            try
            {
                UserOfficeDAO userOfficeDAO = new UserOfficeDAO();
                return userOfficeDAO.GetUserOffice(officeID, userID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserOfficeException, ex);
            }
        }                

        public static UserOfficeCollection GetUserOffices(UserOfficeColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                UserOfficeDAO userOfficeDAO = new UserOfficeDAO();
                return userOfficeDAO.GetUserOffices(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserOfficesException, ex);
            }
        }        

        public static UserOfficeCollection GetUserOffices(UserOfficeColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                UserOfficeDAO userOfficeDAO = new UserOfficeDAO();
                return userOfficeDAO.GetUserOffices(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetUserOfficesException, ex);
            }
        }        

        #endregion
    }
}